// program to illustrate binary operator overloading 


#include<iostream.h>
#include<conio.h>

class complex
{
int r,i;
public:
void getdata ()
{cout<<"Enter the real and imaginary parts of complex number:";
cin>>r>>i;

}
void putdata()
{
cout<<"the resultant complex number is :";
cout<<r<<"+"<<i<<"i";

}
complex operator+(complex p)
{
complex x ;
x.r=p+p.r;
x.i=i+p.i;
return x;

}

}c1,c2,c3;

void main()
{
clrscr();

c1.getdata();
c2.getdata();
c3=c1+c2;
c3.putdata();
getch();

}

/*
output
Enter the real and imaginary parts of complex number: 2 3
Enter the real and imaginary parts of complex number: 3 2
Resultant complex number is :  5+5i
*/